Skip to content

Conversation

@axunonb
Copy link
Collaborator

@axunonb axunonb commented Apr 15, 2025

  • Now all library files have NRT enabled
  • DataTypeSerializerFactory simplified
  • UtcOffsetSerializer.GetOffset(string) simplified

@codecov
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 40.65041% with 146 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Ical.Net/Serialization/SerializerBase.cs 20% 12 Missing and 4 partials ⚠️
Ical.Net/Serialization/DataTypes/EnumSerializer.cs 0% 9 Missing ⚠️
...Serialization/DataTypes/RequestStatusSerializer.cs 18% 4 Missing and 5 partials ⚠️
...al.Net/Serialization/DataTypes/StringSerializer.cs 53% 5 Missing and 4 partials ⚠️
...alization/DataTypes/EncodableDataTypeSerializer.cs 20% 4 Missing and 4 partials ⚠️
...l.Net/Serialization/DataTypes/TriggerSerializer.cs 11% 5 Missing and 3 partials ⚠️
Ical.Net/Serialization/DataTypeMapper.cs 12% 1 Missing and 6 partials ⚠️
...l.Net/Serialization/DataTypes/WeekDaySerializer.cs 30% 3 Missing and 4 partials ⚠️
...l.Net/Serialization/DataTypes/IntegerSerializer.cs 25% 3 Missing and 3 partials ⚠️
...Net/Serialization/DataTypes/OrganizerSerializer.cs 45% 3 Missing and 3 partials ⚠️
... and 22 more

❌ Your patch status has failed because the patch coverage (41%) is below the target coverage (80%). You can increase the patch coverage or adjust the target coverage.
❌ Your project status has failed because the head coverage (66%) is below the target coverage (80%). You can increase the head coverage or adjust the target coverage.

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #772   +/-   ##
===================================
- Coverage    67%    66%   -1%     
===================================
  Files       104    104           
  Lines      4483   4495   +12     
  Branches   1103   1140   +37     
===================================
- Hits       2994   2969   -25     
+ Misses     1064   1061    -3     
- Partials    425    465   +40     
Files with missing lines Coverage Δ
Ical.Net/DataTypes/RequestStatus.cs 21% <ø> (ø)
Ical.Net/Serialization/CalendarComponentFactory.cs 80% <ø> (ø)
....Net/Serialization/DataTypes/DataTypeSerializer.cs 71% <100%> (ø)
....Net/Serialization/DataTypes/DurationSerializer.cs 86% <ø> (ø)
Ical.Net/Serialization/SerializationUtil.cs 87% <100%> (ø)
Ical.Net/Serialization/SerializerFactory.cs 81% <100%> (ø)
Ical.Net/Serialization/SimpleDeserializer.cs 95% <100%> (ø)
Ical.Net/DataTypes/StatusCode.cs 19% <0%> (ø)
Ical.Net/Serialization/CalendarSerializer.cs 32% <50%> (ø)
....Net/Serialization/DataTypes/DateTimeSerializer.cs 83% <0%> (-2%) ⬇️
... and 29 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@axunonb axunonb force-pushed the wip/axunonb/pr/nrt-serialization branch 2 times, most recently from e7a31be to 8112d39 Compare April 15, 2025 14:19
@axunonb axunonb force-pushed the wip/axunonb/pr/nrt-serialization branch from 8112d39 to 1feaa17 Compare April 18, 2025 08:04
@axunonb axunonb marked this pull request as ready for review April 22, 2025 20:19
@axunonb axunonb requested a review from minichma April 22, 2025 20:20
minichma
minichma previously approved these changes Apr 23, 2025
Copy link
Collaborator

@minichma minichma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's a lot of changes. LGTM, just a few thoughts. Skimmed over the code only very briefly though.

var uriValue = Decode(a, attachment);
a.Uri = new Uri(uriValue, UriKind.RelativeOrAbsolute);

if (string.IsNullOrEmpty(uriValue)) return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, returning null is the best option here, is it? Anyhow, it's a functional change, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have another look.

Not sure, returning null is the best option

I believe returning null to avoid throwing exceptions is overused in the codebase. Methods like TryGet(...) would have been a better alternative to returning a NRT. That said, enabling nullable has introduced more null checks but reduced overall coverage. However, this investment will pay off in terms of future code quality.
I've migrated projects to NRT several times, but this particular migration significantly exceeded my initial workload estimates. And that's without the unit tests still ahead of us.

Copy link
Collaborator Author

@axunonb axunonb Apr 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returned value can't be null here, will update the code.
Even if the uriValue were null, it would throw, then the exception is eaten up and null ist returned anyway

try
{
var a = CreateAndAssociate() as Attendee;
if (CreateAndAssociate() is not Attendee a) return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather throw?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have different implementations using this pattern. Leave the current behavior for now.


var uriString = Unescape(Decode(a, attendee));

if (uriString == null) return a;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the behavior is different to AttachmentSerializer, where we return null. I think, this way is better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned value can't be null here when args are not null.


public override object Deserialize(TextReader tr) => Deserialize(tr.ReadToEnd());
}
public override object? Deserialize(TextReader? tr) => tr != null ? Deserialize(tr.ReadToEnd()) : null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it be allowed to pass null as the TextReader? Rather make it not nullable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of overriding the base method, SerializeToString(object? obj) which is nullable

rawOffset = rawOffset.Substring(1, rawOffset.Length - 1);
}
// Supported formats
var formats = new[] { "hhmmss", "hhmm", "hh" };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be declared as static property or field

try
{
var name = Enum.GetName(typeof(DayOfWeek), ds.DayOfWeek);
value += name!.ToUpper().Substring(0, 2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If name is null, it would throw and be catched silently, which is ok, but not too readable. Handle explicitly?

Copy link
Collaborator Author

@axunonb axunonb Apr 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, if (name == null) return null; is more readable

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants